﻿using System;
using System.Windows;
using System.Windows.Media;

namespace WPFTestDemo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            Loaded += MainWindow_Loaded;

            InitializeComponent();
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            MyCustomUIElement.AddLine(new BorderLine()
            { Stroke = Brushes.Yellow, StrokeThickness = 10, StartPoint = new Point(20, 20), EndPoint = new Point(40, 30) });

            MyCustomUIElement.AddLine(new BorderLine()
            { Stroke = Brushes.Yellow, StrokeThickness = 10, StartPoint = new Point(30, 30), EndPoint = new Point(45, 35) });


            //MyCustomUIElement.AddUIElementToVisualTree(new BorderLine()
            //{ Stroke = Brushes.Yellow, StrokeThickness = 10, StartPoint = new Point(0, 0), EndPoint = new Point(400, 300) });

            MyCustomUIElement.InvalidateMeasure();
        }

        Random random = new Random();

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            double x1 = random.Next(0, 400);
            double x2 = random.Next(0, 400);
            double y1 = random.Next(0, 300);
            double y2 = random.Next(0, 300);

            MyCustomUIElement.AddLine(new BorderLine()
            { Stroke = Brushes.Yellow, StrokeThickness = 10, StartPoint = new Point(x1, y1), EndPoint = new Point(x2, y2) });
        }

        private void Button_Click1(object sender, RoutedEventArgs e)
        {
            MyCustomUIElement.Clean();
        }
    }
}
